package com.wiloon.java8x;

import java.util.Random;
import java.util.UUID;

/**
 * Created by Roy on 2015/9/7;
 */
public class StringX {
    public static void main(String[] args) {
        testsub();

    }

    public static void testUUID() {
        String uuid = UUID.randomUUID().toString();
        ;
        System.out.println(uuid);
        System.out.println(uuid.length());
    }

    public static void t() {
        System.out.println(String.valueOf(100).length());
    }

    public static void testsub() {
        String str = "1234567";
        if (str.length() > 5) str = str.substring(0, 5) + "...";
        System.out.println(str);
        str = "1234567";
        if (str.length() > 6) str = str.substring(0, 6) + "...";
        System.out.println(str);

        str = "1234567";
        if (str.length() > 7) str = str.substring(0, 7) + "...";
        System.out.println(str);

        str = "1234567";
        if (str.length() > 8) str = str.substring(0, 8) + "...";
        System.out.println(str);
    }

    public static void test0() {
        String str = String.format("%02d", 1);
        System.out.println("\"" + str);
        for (int i = 0; i < 100; i++) {
            String id = String.format("%02d", Math.abs(new Random().nextInt() % 100));
            System.out.println(id);
        }
    }

    public static void test() {
        String equipmentId = String.valueOf(Math.abs(new Random().nextInt() % 90) + 10);
        System.out.println(equipmentId);
    }
}
